package com.wc.AlgoOJ_homework.AlgoOJ_test3.C_纸上的字;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/3/11 19:06
 * @description http://43.138.190.70:8888/p/983?tid=65e5dab127489dab814f76e2
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[][] css = new char[8][];
        int t = Integer.parseInt(sc.next());

        while (t-- > 0) {
            StringBuffer res = new StringBuffer();
            for (int i = 0; i < 8; i++) {
                css[i] = sc.next().toCharArray();
            }
            for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    while (i < 8 && css[i][j] != '.') {
                        res.append(css[i][j]);
                        i++;
                    }
                    if (res.length() >= 1) break;
                }
            }
            System.out.println(res);
        }

    }
}
